package com.tjhk.lock.service;

import com.tjhk.lock.cas.FairLock;
import com.tjhk.lock.clh.CLHLock;
import com.tjhk.lock.clh.MCSLock;
import org.springframework.stereotype.Service;

import java.util.concurrent.locks.ReentrantLock;

@Service
public class TestService {

    private int num = 5000;
    MCSLock lock = new MCSLock();
//    UnfairCLHLock lock = new UnfairCLHLock();
//    CLHLock lock = new CLHLock();
    public void test(){
        try {
            lock.lock();
            num--;
            System.out.println("还剩："+num);
        } finally {
            lock.unlock();
        }
    }
}
